package com.ljc.config;

import com.ljc.template.HotsTemplate;
import com.ljc.template.PostTemplate;
import com.ljc.template.TimeAgoMethod;
import com.jagregory.shiro.freemarker.ShiroTags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @Author: ljc
 * @Description:
 * @Date:Created in 15:04 2021/12/5
 * @Modified By:
 */
@Configuration
public class FreemarkerConfig {
    @Autowired
    private freemarker.template.Configuration configuration;
    @Autowired
    PostTemplate postTemplate;
    @Autowired
    HotsTemplate hotsTemplate;


    @PostConstruct
    public void setUp() {
        configuration.setSharedVariable("timeAgo", new TimeAgoMethod());
        configuration.setSharedVariable("posts", postTemplate);
        configuration.setSharedVariable("hots",hotsTemplate);
        configuration.setSharedVariable("shiro",new ShiroTags());

    }
}
